package cn.ldw.test;

public class InsertSort {
    public static void main(String[] args) {
        int[] nums = new int[]{2, 1, 5, 3, -1, 2, 3};
        for (int i = 1, j; i < nums.length; i++) {
            int t = nums[i];
            for (j = i - 1; j >= 0 && nums[j] > t; j--) {
                nums[j + 1] = nums[j];
            }
            nums[j + 1] = t;
        }
        for (int num : nums) {
            System.out.println(num);
        }
    }
}
